#include "Parameters.h"


Parameters *Parameters::instance=NULL;

Parameters::Parameters()
{
  doubleVectorParameters=doubleVectorParameters_type();
  doubleParameters["current"]=8E-3;
  doubleParameters["minCurrent"]=0E-3;
  doubleParameters["maxCurrent"]=20E-3;
  doubleParameters["currentStep"]=5E-4;

  doubleParameters["field"]=0;
  doubleParameters["minField"]=-500;
  doubleParameters["maxField"]=500;
  doubleParameters["fieldStep"]=50;

  doubleParameters["angleField"]=0;
  doubleParameters["minAngle"]=0;
  doubleParameters["maxAngle"]=180;
  doubleParameters["angleStep"]=5;

  doubleParameters["angleField2"]=90;
  doubleParameters["minAngle2"]=0;
  doubleParameters["maxAngle2"]=180;
  doubleParameters["angleStep2"]=1;

  doubleParameters["riseTime"]=200E-12;
  doubleParameters["firstPulseLength"]=1.61E-9;
  doubleParameters["pulseEndValue"]=0.5;

  doubleParameters["currentPulseLength"]=2E-9;
  doubleParameters["currentMinPulseLength"]=1E-10;
  doubleParameters["currentMaxPulseLength"]=5E-9;
  doubleParameters["currentPulseLengthStep"]=5E-10;

  doubleParameters["firstCurrentPulseLength"]=2E-9;
  doubleParameters["secondCurrentPulseLength"]=8E-9;
  doubleParameters["firstCurrentPulseAmplitude"]=12E-3;
  doubleParameters["secondCurrentPulseAmplitude"]=12E-3;
  doubleParameters["currentDelay"]=6E-10;
  doubleParameters["currentMinDelay"]=0;
  doubleParameters["currentMaxDelay"]=2E-8;
  doubleParameters["currentDelayStep"]=1E-10;
  doubleParameters["currentMinSecondPulse"]=0;
  doubleParameters["currentMaxSecondPulse"]=1E-9;
  doubleParameters["currentSecondPulseStep"]=1E-11;
  doubleParameters["fieldPulseLength"]=5E-9;
  doubleParameters["fieldMinPulseLength"]=1E-10;
  doubleParameters["fieldMaxPulseLength"]=2E-8;
  doubleParameters["fieldPulseLengthStep"]=1E-10;

  intParameters["numberOfCurrentPulses"]=1;
  stringParameters["currentPulseType"]="doublesquare";

  intParameters["numberOfFieldPulses"]=1;
  stringParameters["fieldPulseType"]="nopulse";


  doubleParameters["timeStep"]=5E-13;
  doubleParameters["maxTimeStep"]=1E-10;
  doubleParameters["timeWindow"]=5E-8;
  doubleParameters["limTorque"]=-10;
  doubleParameters["relAccuracy"]=1E-10;

  doubleParameters["temperature"]=0;
  intParameters["nrun"]=1;

  doubleParameters["sTolerance"]=0;
  intParameters["sLayer"]=1;

  stringParameters["polarization"]="Slonczewski";
  doubleParameters["qplus"]=1;
  doubleParameters["qminus"]=-0.1;
  doubleParameters["b0"]=1;
  doubleParameters["b1"]=0.5;

  intParameters["nbLayer"]=2;
  
  stringParameters["l0_name"]="Hard";
  intParameters["l0_number"]=0;
  doubleParameters["l0_ms"]=500000;
  doubleParameters["l0_alpha"]=0.01;
  doubleParameters["l0_polarization"]=0.1;
  doubleParameters["l0_asymetry"]=0.183;
  doubleParameters["l0_thickness"]=1.8E-9;
  doubleParameters["l0_surface"]=1E-14;
  doubleParameters["l0_ndX"]=0;
  doubleParameters["l0_ndY"]=0;
  doubleParameters["l0_ndZ"]=1;
  doubleParameters["l0_nrX"]=0;
  doubleParameters["l0_nrY"]=0;
  doubleParameters["l0_nrZ"]=0;
  doubleParameters["l0_k"]=3E6;
  doubleParameters["l0_angleAni"]=0;
  doubleParameters["l0_angleAni2"]=90;
  doubleParameters["l0_mx"]=0;
  doubleParameters["l0_my"]=0;
  doubleParameters["l0_mz"]=1;
  boolParameters["l0_frozen"]=true;
  doubleParameters["l0_upExchange"]=0;
  doubleParameters["l0_downExchange"]=0;

  stringParameters["l1_name"]="Free";
  intParameters["l1_number"]=1;
  doubleParameters["l1_ms"]=650000;
  doubleParameters["l1_alpha"]=0.01;
  doubleParameters["l1_polarization"]=0.25;
  doubleParameters["l1_asymetry"]=0.183;
  doubleParameters["l1_thickness"]=1.8E-9;
  doubleParameters["l1_surface"]=1E-14;
  doubleParameters["l1_ndX"]=0;
  doubleParameters["l1_ndY"]=0;
  doubleParameters["l1_ndZ"]=1;
  doubleParameters["l1_nrX"]=0;
  doubleParameters["l1_nrY"]=0;
  doubleParameters["l1_nrZ"]=0;
  doubleParameters["l1_k"]=3.3E5;
  doubleParameters["l1_angleAni"]=0;
  doubleParameters["l1_angleAni2"]=90;
  doubleParameters["l1_mx"]=0;
  doubleParameters["l1_my"]=-0;
  doubleParameters["l1_mz"]=-1;
  boolParameters["l1_frozen"]=false;
  doubleParameters["l1_downExchange"]=0;
  doubleParameters["l1_upExchange"]=0;
  doubleParameters["l1_initialAngle"]=0;
  doubleParameters["l1_finalAngle"]=20;
  doubleParameters["l1_angleStep"]=1;

  stringParameters["l2_name"]="Free2";
  intParameters["l2_number"]=2;
  doubleParameters["l2_ms"]=650000;
  doubleParameters["l2_alpha"]=0.01;
  doubleParameters["l2_polarization"]=0.3;
  doubleParameters["l2_asymetry"]=0.183;
  doubleParameters["l2_thickness"]=3E-9;
  doubleParameters["l2_surface"]=5E-15;
  doubleParameters["l2_ndX"]=0;
  doubleParameters["l2_ndY"]=0;
  doubleParameters["l2_ndZ"]=1;
  doubleParameters["l2_k"]=5E5;
  doubleParameters["l2_angleAni"]=90;
  doubleParameters["l2_angleAni2"]=90;
  doubleParameters["l2_mx"]=0;
  doubleParameters["l2_my"]=0.9;
  doubleParameters["l2_mz"]=0.1;
  boolParameters["l2_frozen"]=false;
  doubleParameters["l2_upExchange"]=0;
  doubleParameters["l2_downExchange"]=0;

  stringParameters["l3_name"]="Free3";
  intParameters["l3_number"]=3;
  doubleParameters["l3_ms"]=650000;
  doubleParameters["l3_alpha"]=0.01;
  doubleParameters["l3_polarization"]=0.1;
  doubleParameters["l3_asymetry"]=0.183;
  doubleParameters["l3_thickness"]=3E-9;
  doubleParameters["l3_surface"]=5E-15;
  doubleParameters["l3_ndX"]=0;
  doubleParameters["l3_ndY"]=0;
  doubleParameters["l3_ndZ"]=0;
  doubleParameters["l3_k"]=0;
  doubleParameters["l3_angleAni"]=34;
  doubleParameters["l3_angleAni2"]=90;
  doubleParameters["l3_mx"]=0.01;
  doubleParameters["l3_my"]=0;
  doubleParameters["l3_mz"]=0.99;
  boolParameters["l3_frozen"]=0;
  doubleParameters["l3_exchange"]=0;
}

Parameters::~Parameters()
{

}

Parameters* Parameters::getInstance()
{
  if (Parameters::instance == NULL)
    {
      Parameters::instance=new Parameters();
    }
  return Parameters::instance;
}

double Parameters::getDouble(const std::string key)
{
  if (doubleParameters.find(key) == doubleParameters.end())
    {
      // erreur
    }
  return doubleParameters.find(key)->second;
}

std::vector<double> Parameters::getDoubleVector(const std::string key)
{
  if (doubleVectorParameters.find(key) == doubleVectorParameters.end())
    {
      // erreur
    }
  return doubleVectorParameters.find(key)->second;
}

int Parameters::getInt(const std::string key)
{
  if (intParameters.find(key) == intParameters.end())
    {
      // erreur
    }
  return intParameters.find(key)->second;
}

bool Parameters::getBool(const std::string key)
{
  if (boolParameters.find(key) == boolParameters.end())
    {
      // erreur
    }
  return boolParameters.find(key)->second;
}

std::string Parameters::getString(const std::string key)
{
  if (stringParameters.find(key) == stringParameters.end())
    {
      // erreur
    }
  return stringParameters.find(key)->second;
}

/*for (doubleParameters_type::iterator i=doubleParameters.begin(); i != doubleParameters.end(); i++)
  {
    i->first;
    i->second[0];
  }
*/
